#include "Timer.h"

Timer::Timer(void)
{
	//Initialize the variables 
	startTicks = 0; 
	pausedTicks = 0; 
	paused = false; 
	started = false; 
	init_firsttime=false;
	interval_ticks=0;
}

Timer::~Timer(void)
{
}
bool Timer::IsStarted() { return started; } 
bool Timer::IsPaused() { return paused; } 
void Timer::Start()
{
	//Start the timer 
	started = true; //Unpause the timer 
	paused = false; //Get the current clock time 
	startTicks = SDL_GetTicks(); 
}
void Timer::Stop()
{
	//Stop the timer 
	started = false; //Unpause the timer 
	paused = false; 
}
int Timer::GetTicks()
{
	//If the timer is running 
	if( started == true ) { 
		//If the timer is paused 
		if( paused == true ) 
		{
			//Return the number of ticks when the timer was paused 
			return pausedTicks; } 
		else { 
			init_firsttime=true;
			//Return the current time minus the start time 
			return SDL_GetTicks() - startTicks; 
		} 
	} //If the timer isn't running 
	return 0; 
}

void Timer::FinishCalculatingInterval()
{
	interval_ticks=this->GetTicks();
	interval_ticks=(this->interval_ticks/1000) * CONSTANT_VELOCITY ;
	
}
bool Timer::IsCalculatingInterval()
{
	return this->init_firsttime;
}

float  Timer::GetIntervals()
{
	return  interval_ticks;
}